1. Field of the Invention
The present invention generally relates to SQL statements. Specifically, the present invention relates to a method, system and program product for rewriting SQL statements.
2. Related Art
Structured query language (SQL) is a standard interactive and programming language for getting information to and from a database. Although SQL is both an ANSI and an ISO standard, many database products support SQL with proprietary extensions to the standard language. Queries take the form of a command language that allows a user to select, insert, update and find the location of data. In a typical implementation, a user will assemble and submit an SQL statement that specifies search criteria. In general, the search criteria includes “search objects” and “search expressions” (e.g., Boolean expressions). For example, if a user wishes to locate all purchase orders within a database having the country code “DE” (e.g., for Germany), OR having one or the customers numbers “001, “002” or “003,” the country code and the customer numbers would represent the “search objects” portion of the search criteria, while the OR would represent the “search expression” portion. As such, the user can assemble a SQL statement such as the following:
SELECT O.customer_po_numFROM bse_order O INNER JOIN cust_order C ON (O.ID = c.order_idand c.order_cust_type = ‘SOLD_TO’)WHERE (O.ISO_COUNTRY_CODE IN (‘DE’) OR(C.CUSTOMER_NUM IN (‘001’,‘002’,‘003’)
Unfortunately, the presence of search expressions such as OR and AND in a SQL statement, cause the query to be extremely slow. This is especially the case as SQL statements become more complex. Heretofore, no approach has alleviated this burden. That is, no existing approach has been able to transform or rewrite SQL statements into more manageable units of work. In view of the foregoing, there exists a need for a method, system and program product for rewriting SQL statements. Specifically, a need exists whereby the search criteria can be separated into smaller units of work or indices that are used to conduct separate, faster searches.